#ifndef QHTTPCLIENT_QHTTP_H
#define QHTTPCLIENT_QHTTP_H


#include "ihttpclient.h"
#include <QtCore/QObject>
#include <QtCore/QEventLoop>
#include <QtNetwork/QHttp>


/**
 * Use Qt's QHttp class as backend.
 * It is proven to not support NTLM proxy
 */
class QHttpClient_QHttp : public QObject, public IHttpClient
{
    Q_OBJECT

public:
    /**
     * Constructor
     */
    QHttpClient_QHttp();
    /**
     * Destructor
     */
    virtual ~QHttpClient_QHttp();

    bool setProxy(const char *szServer, const int iPort,
        const char *szUser = 0, const char *szPassword = 0, const char* szDomain = 0);

    bool getUrlToMem(const char *szUrl, char *szBuffer);

    bool getUrlToFile(const char *szUrl, const char *szLocalFilePath);

    void release() { delete this; }

private slots:
    /**
     * Slot when all requests are done
     * @param error true if error occurred
     */
    void done(bool error);

private:
    /** Whether success or not */
    bool m_bSuccess;
    /** The Http handle */
    QHttp *m_pHttp;
    /** The socket event loop */
    QEventLoop m_eventLoop;

};


#endif
